//
//  NewJieSuanChangeViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/22.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewJieSuanChangeViewController.h"
#import "NewJiesuanYanzhengmaViewController.h"
#import "JTCSM.h"

@interface NewJieSuanChangeViewController ()
{
    CGFloat backImageviewHeight;
    CGFloat showWidth;
    CGFloat backSpace;
    UIImageView *bankImagev;
    CGFloat imageHeight;
    CGFloat imagewidth;
}
@end

@implementation NewJieSuanChangeViewController

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor =RGBACOLOR(241, 241, 241, 1);
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    imagewidth = 30*[JTCSMSingle shareSingle].adaptationNumber;
    imageHeight = imagewidth*68/81;
    [self layoutSubviews];
}

- (void)layoutSubviews{
    CGFloat space = 40*[JTCSMSingle shareSingle].adaptationNumber;
    CGFloat backImageviewWidth = KCONTROLLERWith-2*space;
    backImageviewHeight = backImageviewWidth/0.66112;
    backSpace = backImageviewWidth*0.0302115;
    CGFloat backtop = backImageviewHeight*0.0302115/2;
    
    bankImagev = [[UIImageView alloc]initWithFrame:CGRectMake(space, space+KagainChangeHeight, backImageviewWidth, backImageviewHeight)];
    bankImagev.image = [UIImage imageNamed:@"更换结算卡背景.png"];
    [self.view addSubview:bankImagev];
    showWidth = backImageviewWidth-2*backSpace;
    UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(backSpace, backtop, showWidth, 40*[JTCSMSingle shareSingle].adaptationNumber) text:@"用户须知" font:16 textAlignment:NSTextAlignmentCenter texcolor:[df colorWithHexString:@"333333" alpha:1] backgroundColor:nil];
    [bankImagev addSubview:titleLabel];
    CGFloat contentLabelSpace = 30*[JTCSMSingle shareSingle].adaptationNumber;
    UILabel *contentLable = [UILabel initWithFrame:CGRectMake(titleLabel.LC_x+contentLabelSpace, KVIEW_Y(titleLabel)+20*[JTCSMSingle shareSingle].adaptationNumber, showWidth-2*contentLabelSpace, 20) text:@"为了确保资金安全，蜂窝用户需要提供相关身份验证资料及变更申请函，申请周期为5个工作日。" font:13 textAlignment:NSTextAlignmentLeft texcolor:[df colorWithHexString:@"999999" alpha:1] backgroundColor:nil];
    [bankImagev addSubview:contentLable];
    contentLable.numberOfLines = 0;

   CGFloat contentHeight = [df getSpaceLabelLineSpacing:12*[JTCSMSingle shareSingle].adaptationNumber withFont:[UIFont systemFontOfSize:13] withLabel:contentLable];
contentLable.frame = CGRectMake(contentLable.LC_x, contentLable.LC_y, contentLable.LC_width, contentHeight);
    
  UIView *lineview = [df newlineViewWithHeightofTop:KVIEW_Y(contentLable)+20*[JTCSMSingle shareSingle].adaptationNumber superView:bankImagev spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:1];
    
    CGFloat changeTop = KVIEW_Y(lineview);
    NSArray *titleArray = @[@"验证用户身份",@"验证新卡信息",@"提交证件材料",@"等待运营审核"];
    NSArray *imageNameArray = @[@"用户身份icon.png",@"新卡icon.png",@"证件资料icon",@"等待审核icon.png"];
    CGFloat buttonSize = backImageviewWidth*0.26473;
    CGFloat buttonTop = backImageviewHeight*0.8674;
    CGFloat infotop = (backImageviewHeight*0.75-changeTop-imageHeight*titleArray.count)/5;
    
    for (int i = 0; i < titleArray.count; i++) {
        [self setInfoViewWithTitle:titleArray[i] imagename:imageNameArray[i] top:changeTop+infotop+(imageHeight+infotop)*i];
    }
    
    UIImageView *buttonImageV = [[UIImageView alloc]initWithFrame:CGRectMake(bankImagev.center.x-space-buttonSize/2, buttonTop-buttonSize/2, buttonSize, buttonSize)];
    buttonImageV.image = [UIImage imageNamed:@"继续更换按钮.png"];
    [bankImagev addSubview:buttonImageV];
    [df layerWithView:buttonImageV radius:buttonSize/2 width:0 color:nil];
    buttonImageV.userInteractionEnabled = YES;
    bankImagev.userInteractionEnabled = YES;
    [df addTapGestureRecognizerWithTarget:self action:@selector(gotoNextVC) andaddView:buttonImageV];
    
    
}

- (void)setInfoViewWithTitle:(NSString *)title imagename:(NSString *)imagename top:(CGFloat)mytop{
    
    
    CGFloat font = 14;
    CGRect rect = [df labelHeightWithContent:title width:1000 font:font];
    CGFloat labelWidth = rect.size.width;
    CGFloat changeSpace = 14;
    CGFloat spact = (showWidth-imagewidth-labelWidth-changeSpace)/2;
    UIImageView *mybankImagev = [[UIImageView alloc]initWithFrame:CGRectMake(spact+backSpace, mytop, imagewidth, imageHeight)];
    mybankImagev.image = [UIImage imageNamed:imagename];
    [bankImagev addSubview:mybankImagev];
    
    UILabel *label = [UILabel initWithFrame:CGRectMake(KVIEW_X(mybankImagev)+changeSpace, mytop, labelWidth, imageHeight) text:title font:font textAlignment:NSTextAlignmentCenter texcolor:[df colorWithHexString:@"333333" alpha:1] backgroundColor:nil];
    [bankImagev addSubview:label];

}
- (void)gotoNextVC{
    NewJiesuanYanzhengmaViewController *vc = [[NewJiesuanYanzhengmaViewController alloc]init];
    vc.nameTitle = @"验证身份";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
